This note provide theoretical details about using CDE to solve the parameters needed for generic demand equations.
Recall that the implicitly additive expenditure function form of CDE is

Where
: N parameters which determines substitution possibilities of commodities in consumption,
< 1. SUBPAR
: N expansion parameters. They appear owing to non-homotheticity in consumption.
> 0. INCPAR.
: scale parameters to specific the function.
> 0
Use CDE parameter to calculate APE, EY and EP
The price and income elasticities are functions of budget shares (CONSHR) and SUBPAR and INCPAR.
If the substitution parameters
are rewritten as
, then Allen partial elasticities of substitution (
) are expressed as:

Where:

: expenditure share, CONSHR
We call this functional form "constant difference in elasticity" because the difference between Allen partial elasticities of substitution
and
are independent of index i:
To show it:
Then we have the income elasticity of demand as:

The compensated cross-price elasticity of demand as:

And the compensated own-price elasticity of demand as:
Or, we can write those equations In another notion (representing parameters with letters instead of Greek letter).
The income elasticity of commodity i is:

The APE between commodities i and k as:

And the APE for commodity i's own price as:
Then compensated (hicksian) price elasticity of demand is:
Note: in some materials, CP is also denoted as COMPDEM
With CP available, we can have EP according to Slutsky decomposition (see the note of generic demand equation)
Note
in my words, the logic flow of this section is:
What we have:
CONSHR from data, SUBPAR and INCPAR from CDE function
What we want:
EY and EP for the linearized generic demand equation (the utility function used in the code)
The approach we take:
SUBPAR → α
α,. INCPAR, CONSHR → EY
α, CONSHR → APE → CP → EP